1. Field of the Invention
The invention generally relates to storing and retrieving data on a disc drive.
2. Background of the Related Art
Disc drives are capable of storing large amounts of digital data in a relatively small area. Disc drives store information on one or more recording media. The recording media conventionally takes the form of a circular storage disc, e.g., media, having a plurality of recording tracks. Conventional disc drives include a plurality of vertically aligned storage discs, each with at least one magnetic head for reading or writing information to the media. Typically, the magnetic head is attached to a positioner arm assembly that uses a motor to align the magnetic head above a selected track on the disc. The location of the magnetic head is typically determined by a disc controller that is given the position of a data area on the disc to read or write data. The precise location and movement of the head is typically accomplished by incorporating a closed-loop electromechanical servo system with a dedicated servo region, or regions, used to provide high speed or continuous feedback to the system to maintain accurate positioning of the data head.
Generally, data is stored on the media in data sectors within each recording track, i.e., a cylinder. As the media is generally round, the number of data sectors per each cylinder on the outer portion of the media is greater than the number of sectors found on cylinders located closer to the center portion of the media. The time needed to access and/or store data is known as the xe2x80x9cseek timexe2x80x9d and is generally a function of the response of the closed loop electromechanical servo system to move the magnetic head(s) from one data sector to another. Generally, the outer cylinders typically have faster access as the positioner arm moves less to read and write data.
Due to their large storage capacity relative to other forms of electronic digital data storage, disc drives are often used by electronic systems such as computers to permanently or semi-permanently store applications, e.g., software programs, data, etc. The amount of data stored on disc drives is a function of the media density, size, and number of medias used. The applications are generally stored as files that are then used by an end user, or users, to perform tasks such as word processing, calculations, and the like. To assist the applications in locating a file, conventional computer operating systems generally use a layered directory structure. The conventional layered directory structures usually have a main directory and then sub directories where the files are stored. For example, using the DOS operating system, a file named xe2x80x9cxyzxe2x80x9d may be given a logical location such as xe2x80x9cc:/xyzxe2x80x9d indicating that the file is located on the xe2x80x9ccxe2x80x9d drive at a root directory xe2x80x9c/xe2x80x9d.
To allow an application to find and use files on the media, each file is given a different logical address location on the media by the computer operating system. Operating systems communicate with the disc drive using logical block addresses (LBA). When an application makes a request for a file from the operating system, the operating system uses the file name to look up the location in terms of a starting LBA and the number of LBAs needed to read or write the file. The LBA is then translated by internal disc drive software to the actual physical location on the disc drive, ie., the physical block address (PBA). The PBA may include a number of data sectors depending upon the translation scheme used on the media for storing data. The translation from LBA to PBA is necessary to allow the disc drive to implement a defect management scheme and to set aside reserved areas on the media for manufacturer specific data, disc drive operating firmware, and other data not generally accessible to the operating system.
As files are written to the drive, the files are allocated to available LBAs. Ideally, each file would be contiguous, i.e., be located in contiguous LBAs. However, due to the media defects, file deletion, and file sizes, the file may be split, i.e., fragmented, so that the sectors containing one file are not contiguous but are surrounded on both sides by sectors having data that belong to other files. Depending on the drives available space, file size, and the current file allocation the location of the fragmented file parts may be located randomly on the media. As seek times negatively impact file storage and retrieval times, increased file fragmentation degrades the application speed and efficiency as the head moves across the media seeking the file fragments. As files are modified by additions, deletions, defects, etc, the operating system maintains the new LBA locations of the data for each file often storing the location of the fragments within a xe2x80x9cfile headerxe2x80x9d. To help minimize the impact of file fragmentation, most operating systems use a defragmentation process to xe2x80x9cdefragmentxe2x80x9d the files. The defragmentation process locates a fragmented file in terms of LBAs, and moves the fragmented file LBAs so that the LBAs are generally contiguous. Unfortunately, as the LBA blocks required may not fully utilize the available PBAs, the files may not be optimally defragmented thereby leaving unused PBAs segments, physically fragmenting the file. Fragmented PBAs may reduce the storage capacity of the media and increase seek times. Further, when run concurrently with other applications, the defragmentation process may negatively affect the performance e.g., speed, of the other applications. To overcome the defragmentation impact on system resources, defragmentation is often performed when other applications are not running. Still further, the operating system defragmentation relies upon available media space in terms of free LBAs. Therefore, for a media that is full, defragmentation may not be possible unless the user creates media space by moving or deleting files.
Thus, what is needed is a method that allows for effective defragmentation of a disc drive that may be run concurrently with applications without system resource degradation.
Aspects of the invention have particular advantages in electronic data storage systems. In one embodiment, the invention generally provides a method and apparatus for storing data to a disc drive, including determining the data storing size of one or more free contiguous physical block addresses, then determining the data size of a least one or more fragmented files, then if the data storing size of at least one contiguous physical block addresses is at least as large as the data size of at least one of the fragmented files, then writing at least one of the fragmented files to the contiguous physical block address where the total data size of the one or more fragmented files does not exceed the contiguous physical block address data storing size.
In another embodiment, the invention provides a method of storing data to a disc drive including combining at least two available physical block addresses into at least one contiguous physical block address, then locating at least one fragmented file to the at least one contiguous physical block addresses wherein the data storing size of the contiguous physical block address is at least as large as the at least one fragmented file, combining the fragmented file to form at least one contiguous file, and writing the at least one contiguous file to the at least one contiguous physical block address to form at least one contiguous defragmented file.
In still another embodiment, the invention provides a disc drive system including a signal-bearing media means for storing data, a code memory means coupled to a read/write controller means for controlling the reading and writing of data to the signal-bearing media, means for reading and writing the data to the signal-bearing media, and a processor means coupled to the code memory and the read/write controller for defragmenting the data on the signal-bearing media means.